package com.peter.framework.service.urlfetch;

import java.io.IOException;
import java.net.URL;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.appengine.api.urlfetch.HTTPResponse;
import com.google.appengine.api.urlfetch.URLFetchService;
import com.google.appengine.api.urlfetch.URLFetchServiceFactory;
import com.google.inject.Singleton;

@Singleton
public class GoogleLLHttpService implements HttpService {

	protected final Logger logger = LoggerFactory.getLogger(getClass());

	@Override
	public String getFromUrl(URL url) throws IOException {
		logger.debug("getFromUrl() url = {}", url);

		logger.debug("urlFetchService");
		URLFetchService urlFetchService = URLFetchServiceFactory
				.getURLFetchService();
		HTTPResponse response = urlFetchService.fetch(url);
		return new String(response.getContent(), "UTF-8");
	}

}
